import request from '@/utils/request'

// 采购入库单开始---------------------------

export function getEntryMaxCode(params) {
  return request({
    url: '/base/entry_code/',
    method: 'GET',
    params
  })
}

export function getEntryCodeList(params) {
  return request({
    url: '/purchase/entry_list/',
    method: 'GET',
    params
  })
}


export function getEntries(params) {
  return request({
    url: '/purchase/entry/',
    method: 'GET',
    params
  })
}


export function addEntry(data) {
  return request({
    url: '/purchase/entry/',
    method: 'POST',
    data
  })
}


export function updateEntry(data) {
  return request({
    url: `/purchase/entry/${data.id}/`,
    method: 'PUT',
    data
  })
}

export function delEntry(id) {
  return request({
    url: `/purchase/entry/${id}/`,
    method: 'DELETE',
  })
}

export function delEntries(data) {
  return request({
    url: `/purchase/entry/batch_delete/`,
    method: 'DELETE',
    data
  })
}

export function delEntryDetails(data) {
  return request({
    url: `/purchase/entry_detail/batch_delete/`,
    method: 'DELETE',
    data
  })
}

// 采购入库单结束----------------------------


// 采购付款单开始---------------------------

export function getPurchasePayMaxCode() {
  return request({
    url: '/base/purchase_pay_code/',
    method: 'GET'
  })
}

export function getPurchasePayOrders(params) {
  return request({
    url: '/purchase/pay_order/',
    method: 'GET',
    params
  })
}


export function addPurchasePayOrder(data) {
  return request({
    url: '/purchase/pay_order/',
    method: 'POST',
    data
  })
}


export function updatePurchasePayOrder(data) {
  return request({
    url: `/purchase/pay_order/${data.id}/`,
    method: 'PUT',
    data
  })
}

export function delPurchasePayOrder(id) {
  return request({
    url: `/purchase/pay_order/${id}/`,
    method: 'DELETE',
  })
}

export function delPurchasePayOrders(data) {
  return request({
    url: '/purchase/pay_order/batch_delete/',
    method: 'DELETE',
    data
  })
}

export function delPurchasePayOrderDetails(data) {
  return request({
    url: `/purchase/pay_order_detail/batch_delete/`,
    method: 'DELETE',
    data
  })
}
// 采购付款单结束----------------------------

//入库对账单
export function getPurchaseBill(params){
  return request({
    url: 'purchase/purchase_bill/',
    method: 'GET',
    params
  })
}

export function downloadPurchaseBill(params){
  return request({
    url: 'purchase/purchase_bill/',
    method: 'GET',
    params,
    responseType: 'blob'
  })
}